<?php

include '../!inc.php';
session_start();

use StudyBuddy\Registry;

function update($collection = 'QUESTIONS') {
    global $oRegistry;
    $coll = $oRegistry->Mongo->getCollection($collection);
    $cur = $coll->find(array('comments' => array('$ne' => null)), array('_id', 'comments'));
    echo 'Found: ' . $cur->count();
    if ($cur->count() > 0) {
        foreach ($cur as $row) {
            $row['a_comments'] = $row['comments'];

            $coll->update(array('_id' => $row['_id']), array('$set' => array('a_comments' => $row['comments']), '$unset' => array('comments' => 1))); //, '$unset' => array('comments' => 1)
        }
    }
}

update();
update('ANSWERS');
